<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<script type="text/javascript">
		window.onload = function(){
			// 删除
			var a = document.getElementsByTagName('a');
			for(var i = 0; i < a.length; i++){
				a[i].onclick = function(){
					var tr = this.parentNode.parentNode;
					var td = tr.getElementsByTagName('td')[0].innerHTML;
					var flag = confirm('确认删除' + td + '吗？');
					if(flag){
						tr.parentNode.removeChild(tr);
					}
				}
			}
			
			function de(){
				var tr = this.parentNode.parentNode;
				var td = tr.getElementsByTagName('td')[0].innerHTML;
				var flag = confirm('确认删除' + td + '吗？');
				if(flag){
					tr.parentNode.removeChild(tr);
				}
			}
			// 添加
			var qa = document.getElementById('qa');
			qa.onclick = function(){
				var qw = document.getElementById('qw').value;
				var as = document.getElementById('as').value;
				var zx = document.getElementById('zx').value;
				var tr = document.createElement('tr');
				tr.innerHTML = "<td>"+qw+"</td>"+
								"<td>"+as+"</td>"+
								"<td>"+zx+"</td>"+
								"<td><a href='javascript:;'>删除</a></td>";
				var a = tr.getElementsByTagName('a')[0];
				a.onclick = de;
				var ta = document.getElementById('ta');
				ta.appendChild(tr);
			}
		}
	</script>
	<body>
		<table border="" cellspacing="0" id="ta">
					<tr>
						<td>1111</td>
						<td>1111</td>
						<td>1111</td>
						<td><a href="javascript:;">删除</a></td>
					</tr>
					<tr>
						<td>222</td>
						<td>222</td>
						<td>222</td>
						<td><a href="javascript:;">删除</a></td>
					</tr>
					<tr>
						<td>222</td>
						<td>222</td>
						<td>222</td>
						<td><a href="javascript:;">删除</a></td>
					</tr>
				</table>
				<br>
				
				<table border="0">
					<tr>
						<td>1111</td>
						<td><input id="qw"/></td>
					</tr>
					<tr>
						<td>1111</td>
						<td><input id="as"/></td>
					</tr>
					<tr>
						<td>1111</td>
						<td><input id="zx"/></td>
					</tr>
					<tr>
						<td><input type="submit" id="qa"/></td>
					</tr>
				</table>
	</body>
</html>
